/**
 * @file 封装 localStorage 操作
 */
const storage = {
  // 设置 localStorage
  set(key: string, value: string) {
    localStorage.setItem(key, JSON.stringify(value));
  },

  // 从 localStorage 获取信息
  get(key: string) {
    const data = localStorage.getItem(key);
    return data ? JSON.parse(data) : null;
  },

  // 删除个别信息
  remove(key: string) {
    localStorage.removeItem(key);
  },

  // 删除所有信息
  removeAll() {
    localStorage.clear();
  },
};

export { storage };
